package com.leanyuan.main.util;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.leanyuan.main.domain.RepReg;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.jdbc.SQL;

public class Form$RegProvider {
    public String selectRepRegSql(@Param("page") Page<RepReg> page, @Param("dto") RepRegDto dto){
        return new SQL(){
            {
                SELECT("*");
                FROM("rep_form a");
                INNER_JOIN("rep_reg b on a.form_id=b.form_id");
                if(dto.getName()!=null){
                    WHERE("b.name like concat('%',#{dto.name},'%')");
                }
                if(dto.getWorkId()!=null){
                    WHERE("b.work_id like concat('%',#{dto.workId},'%') ");
                }
                if(dto.getPhone()!=null){
                    WHERE("b.phone like concat('%',#{dto.phone},'%')");
                }
                if(dto.getStatus()!=null){
                    WHERE("b.work_statu=#{dto.status}");
                }
                ORDER_BY("addtime desc");
            }
        }.toString();
    }
}
